﻿@model ShortUrl.Models.UrlModel
@{
    ViewBag.Title = "Главная страница";
}

<h2>@ViewBag.Message</h2>
<p>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    <fieldset>
        <legend>Ссылка для сокращения</legend>
        <div class="editor-field">
        @Html.EditorFor(model => model.LongUrl)
        </div> <input type="submit" value="Преобразовать" />
    </fieldset>
}
</p>
<table>
    <tr>
        <th></th>
        <th>
            Long Url
        </th> 
        <th>
            Short Key
        </th>
        <th></th>
        <th>
            Click
        </th>
        <th>
            Date
        </th>
    </tr>
 @foreach (var item in Model.Urls)
 {
    <tr>
        <td>
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
        <td>
            @Html.ActionLink(item.LongUrl, "ClickUrl", new { id = item.Id }, new { target = "blank_" })
        </td>
        <td>
             @Html.ActionLink(@Request.Url+item.ShortKey, "ClickUrl", new { id = item.Id }, new { target = "blank_" })
        </td>
        <td>
        </td>
        <td>
            @item.ClickUrl
        </td>
        <td>
            @item.Date.ToShortDateString()
        </td>
    </tr>
}

</table>
